/*
 * Main.cpp
 *
 *  Created on: Jan 23, 2012
 *      Author: hduser
 */

#include<iostream>
#include<exception>
#include "CloudClient.h"
#include "ExceptionHandler.h"

using namespace std;
using namespace cloud;
using namespace utilities;

/*********************************************************/
/* MAIN FUNCTION  	         							 */
/*********************************************************/

int main() {

	// hdfs test
/*
	cout<<"Helper class starts here"<<endl;

	CloudClient* client = new CloudClient("localhost", 54310);

	client->writeFileToHDFS("/media/20A2-4F25/movie/3ID7OT5.crazy.mkv","hdfs3ID7OT5.crazy.mkv");
	cout<<"File Write Completed"<<endl;

	client->getFileFromHDFS("hdfs3ID7OT5.crazy.mkv","/home/hduser/testfiles/hdfs3ID7OT5.crazy.mkv");
	cout<<"File Read Complete"<<endl;
	client->cloudConn->Close();

	cout<<"Complete"<<endl;
*/

	// exception handling test
/*
	try {

		cout<<"test exception"<<endl;
		//int i = 1;
		//int j = 0;
		//int k = i/j;

		//char* s = "a";
		//char c = s[2];

		int x = 0;
		if (x!=0)
			cout << "test";
		else
			throw(x);

	} catch (...) {
		cout<<"caught exception"<<endl;
		ExceptionHandler::processException("main()", "test");
	}
*/

	char* d = "abc   p  ";
	char* s = "def   r";

	char* buffer = (char*)malloc(9);
	memcpy(buffer, d, 9);
	buffer = realloc(buffer, 19);
	int length = 9;
	memcpy(buffer + length, s, 7);

	cout<<d<<endl;
	cout<<s<<endl;
	cout<<buffer<<endl;

}
